<%@ taglib prefix="tiles" uri="http://tiles.apache.org/tags-tiles" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions"%>

<div id="heading" class="section">
    <h2>User Results</h2>
</div>
<p>
    <a id="changeSearchLink" href="index?&search=${search}&pageSize=${pageSize}">Change Search</a>
    <script type="text/javascript">
	Spring.addDecoration(new Spring.AjaxEventDecoration({
	    elementId: "changeSearchLink",
	    event: "onclick",
	    popup: true,
	    params: {fragments: "searchForm"}		
	}));
    </script>
</p>
<div id="hotelResults" class="section">
    <c:if test="${not empty users}">
	<table class="summary">
	    <thead>
		<tr>
		    <th>Name</th>
		    <th>Action</th>
		</tr>
	    </thead>
	    <tbody>
		<c:forEach var="user" items="${users}">
		    <tr>
			<td>${user.name}</td>
			<td><a href="show?id=${user.id}&persistentClassName=${searchCriteria.persistentClassName}&searchString=${searchCriteria.searchString}&pageSize=${searchCriteria.pageSize}">View User</a></td>
		    </tr>
		</c:forEach>
		<c:if test="${empty users}">
		    <tr>
			<td colspan="5">No users found</td>
		    </tr>
		</c:if>
	    </tbody>
	</table>
	<div class="buttonGroup">
	    <c:if test="${searchCriteria.page > 0}">
		<a id="prevResultsLink" href="search?persistentClassName=${searchCriteria.persistentClassName}&searchString=${searchCriteria.searchString}&pageSize=${searchCriteria.pageSize}&page=${searchCriteria.page - 1}">Previous Results</a>
		<script type="text/javascript">
		    Spring.addDecoration(new Spring.AjaxEventDecoration({
			elementId: "prevResultsLink",
			event: "onclick",
			params: {fragments: "body"}
		    }));
		</script>
	    </c:if>
	    <c:if test="${not empty users && fn:length(users) == searchCriteria.pageSize}">
		<a id="moreResultsLink" href="search?persistentClassName=${searchCriteria.persistentClassName}&searchString=${searchCriteria.searchString}&pageSize=${searchCriteria.pageSize}&page=${searchCriteria.page + 1}">More Results</a>
		<script type="text/javascript">
		    Spring.addDecoration(new Spring.AjaxEventDecoration({
			elementId: "moreResultsLink",
			event: "onclick",
			params: {fragments: "body"}		
		    }));
		</script>
	    </c:if>		
	</div>
    </c:if>
</div>	

